#include <iostream>
#include <string.h>
using namespace std;

class Solution {
public:
    /**
     * 代码中的类名、方法名、参数名已经指定，请勿修改，直接返回方法规定的值即可
     *
     * 
     * @param param string字符串 
     * @return string字符串
     */
    string compressString(string param) {
        // write code here
        int n = param.size();
        string ans;
        char ch = param[0];
        int sum = 1;
        for(int i = 1;i < n;i++)
        {
            if(ch == param[i])
            {
                sum++;
            }
            else {
                
                ans+=ch;
                if(sum != 1)
                {
                    ans+=to_string(sum);
                }
                sum = 1;
                ch = param[i];
            }
        }
        ans+=param[n-1];
        if(sum != 1)
        {
            ans+=to_string(sum);
        }
        cout << ans << endl;
        return ans;
    }
};